<% include("/layout/header.html",{title:"销售管理",gate:"sell"}){}%>
<div class="container">
    <button class="btn btn-primary" onclick="showAdd()">添加</button>
    <table class="table table-auto table-striped table-hover table-bordered table-condensed">
        <thead>
        <tr>
            <th>商品名称</th>
            <th>销售数量</th>
            <th>销售单价</th>
            <th>销售总价</th>
            <th>销售时间</th>
            <th>库存数量</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <%
        for(var sell in queryResult.list!){
        %>
        <tr id="${sell.id!}">
            <td>${sell.goods.name!}</td>
            <td>${sell.count!}</td>
            <td>${sell.goods.outPrice!}￥</td>
            <td>${sell.goods.outPrice!0*sell.count!0}￥</td>
            <td>${sell.createTime!,"yyyy-MM-dd HH:mm:ss"}</td>
            <td>${sell.goods.stock!}</td>
            <td>
                <button onclick="delSell('${sell.id!}')" class="btn btn-danger btn-sm">删除</button>
            </td>
        </tr>
        <%
        }
        %>
        </tbody>
    </table>
    <ul class="pager" data-ride="pager" data-page="${queryResult.pager.pageNumber!1}" data-rec-total="${queryResult.pager.recordCount!0}" data-rec-per-page="${queryResult.pager.pageSize!}" data-link-creator="${base}/purchase?pageNumber={page}&pageSize={recPerPage}"></ul>
</div>
<div class="modal fade" id="myModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">关闭</span></button>
                <h4 class="modal-title">添加销售单</h4>
            </div>
            <div class="modal-body">
                <form action="${base}/sell/add" method="post" class="form-horizontal" id="sellForm">
                    <div class="form-group">
                        <label for="goodsId" class="col-sm-2">商品名称</label>
                        <div class="col-md-6 col-sm-10">
                            <select class="chosen-select form-control" id="goodsId" name="goodsId" onchange="goodsChange()">
                                <%
                                    for(var goods in goodsList){
                                        %>
                                        <option value="${goods.id!}">${goods.name!}</option>    
                                        <%
                                    }
                                %>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="stock" class="col-sm-2">库存数量</label>
                        <div class="col-md-6 col-sm-10">
                            <input type="number" class="form-control" id="stock" name="stock" placeholder="货物库存" readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="outPrice" class="col-sm-2">商品售价</label>
                        <div class="col-md-6 col-sm-10">
                            <input type="number" class="form-control" id="outPrice" name="outPrice" placeholder="货物售价" readonly="readonly">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="count" class="col-sm-2">销售数量</label>
                        <div class="col-md-6 col-sm-10">
                            <input type="number" class="form-control" id="count" name="count" placeholder="销售数量">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="saveSell()">保存</button>
            </div>
        </div>
    </div>
</div>
<% include("/layout/pwd.html"){}%>
<!-- jQuery (ZUI中的Javascript组件依赖于jQuery) -->
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<!-- ZUI Javascript组件 -->
<script src="${base}/js/zui.min.js"></script>
<script src="${base}/js/common.js"></script>
<script src="${base}/js/sell.js"></script>
</body>
</html>